      SUBROUTINE TGLOC02(NTARGS,TARGNAME,NPARMS,PARMS,
     *    KSYSNAT,KCENNAT,TARGPOS,LUERR,IERR)
      IMPLICIT REAL*8 (A-H,O-Z)
C
C THIS ROUTINE IS PART OF THE TOSS TARGET LOCATION PACKAGE, TGLOC. IT
C COMPUTES THE POSITION OF AN EARTH-FIXED TARGET IN THE EARTH-FIXED
C SYSTEM.
C
C VAR     DIM    TYPE I/O DESCRIPTION
C ---     ---    ---- --- -----------
C
C NTARGS   1      I*4  I  NUMBER OF TARGETS TO BE PROCESSED.
C                         IF ZERO OR NEGATIVE, NONE ARE PROCESSED.
C
C TARGNAME NTARGS CH*16 I TARGET NAMES;  USED FOR ERROR MESSAGES,
C                         OTHERWISE THE NAME HAS NO SIGNIFICANCE.
C
C NPARMS   1      I*4  I  THE NUMBER OF PARAMETERS SUPPLIED IN THE PARMS
C                         ARRAY.  MUST BE 4 OR GREATER.
C
C PARMS           R*8  I  SAME AS TGLOC'S DESCRIPTION OF PARMS FOR
C    NPARMS,NTARGS        TARGET TYPE 2.
C
C KSYSNAT  1      I*4  O  IDENTIFIES THE NATURAL COORDINATE SYSTEM'S
C                         ORIENTATION.  IS SET TO 10 TO INDICATE THE
C                         ORIENTATION IS EARTH-FIXED; IE,  PRINCIPAL
C                         PLANE IS EARTH EQUATOR AND PRINCIPAL
C                         DIRECTION IS THROUGH THE GREENWICH MERIDIAN.
C
C KCENNAT  1      I*4  O  IDENTIFIES THE NATURAL COORDINATE SYSTEM'S
C                         ORIGIN.  IS SET TO 1 TO INDICATE THE ORIGIN IS
C                         THE EARTH CENTER.
C
C TARGPOS 3,NTARGS R*8 O  TARGPOS(-,I) IS THE POSITION OF THE I'TH
C                         TARGET.  COORDS ARE IN GEOCENTRIC, EARTH-
C                         FIXED COORDINATES.  IN KM.
C
C LUERR    1      I*4  I  FORTRAN UNIT NUMBER FOR ERROR MESSAGES.
C                          = 0/NEGATIVE, NO MESSAGES POSSIBLE.
C
C IERR     1      I*4  O  ERROR RETURN FLAG.
C                          = 0, NO ERROR.
C                          = OTHERWISE, ERROR.
C
C***********************************************************************
C
C BY C PETRUZZO, GSFC/742, 8/85.
C        MODIFIED....
C
C***********************************************************************
C
      REAL*8 PARMS(NPARMS,1),TARGPOS(3,1)
      CHARACTER*16 TARGNAME(1)
C
C
      IERR = 0
      KSYSNAT = 10   ! GEOGRAPHIC (EARTH FIXED)
      KCENNAT = 1    ! ORIGIN IS EARTH CENTER
      IF(NTARGS.LE.0) GO TO 9999
C
      ERAD =  CONST(53)
      EFLAT = CONST(59)
C
C GET TARGET POSITION VECTORS IN 'NATURAL' SYSTEM.
C
      DO ITARG = 1,NTARGS
        CALL TGLOC02A(NPARMS,PARMS(1,ITARG),TARGNAME(ITARG),LUERR,IERR1)
        IF(IERR1.EQ.0) THEN
          GLAT =  PARMS(1,ITARG)
          GLONG = PARMS(2,ITARG)
          ALT =   PARMS(3,ITARG)
          FLAT =  PARMS(4,ITARG)
          IF(FLAT.NE.0.D0) FLAT = EFLAT
          CALL TOPCENXYZ(GLAT,GLONG,ALT,ERAD,FLAT,TARGPOS(1,ITARG))
        ELSE
          IERR = 1
          TARGPOS(1,ITARG) = 'ERROR'
          TARGPOS(2,ITARG) = 'ERROR'
          TARGPOS(3,ITARG) = 'ERROR'
          END IF
        END DO
C
 9999 CONTINUE
      RETURN
      END
